package com.woniuxy.hotel.room.controller;

import java.util.List;

import com.woniuxy.hotel.room.util.LayUiDataResultDTO;
import com.woniuxy.hotel.room.service.imp.HotelServiceImp;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.woniuxy.hotel.room.pojo.Hotel;
import com.woniuxy.hotel.room.pojo.HotelWithBLOBs;

import javax.annotation.Resource;


@Controller
@RequestMapping("/hotel")
public class HotelController {

	@Resource
	private HotelServiceImp hotelServiceImp;
	
	/*
	 * 找到所有酒店
	 */
	@RequestMapping("/findHotel")
	@ResponseBody
	public List<HotelWithBLOBs> findHotel(){
		return hotelServiceImp.findHotel();
	}
	
	@RequestMapping("/allHotelInfo")
	@ResponseBody
	public LayUiDataResultDTO allHotelInfo(Integer page,Integer limit){
		List<HotelWithBLOBs> a= hotelServiceImp.limitHotelInfo(page,limit);
		LayUiDataResultDTO<List> dto=new LayUiDataResultDTO<>(0, "", a, hotelServiceImp.countNum());
		System.out.println(a);
		return dto;
	}
	
	/*找到酒店
	 * 动态Sql
	 * 支持所有字段
	 * */
	@RequestMapping("/findHotelSql")
	@ResponseBody
	public List<Hotel> findAllHotel(Hotel hotel){
		return hotelServiceImp.findHotelSql(hotel);
	}
	
	/*
	 * 查看这个酒店的详情,显示图片,描述等s
	 * */
	@RequestMapping("/findHotelSqlBLOBs")
	@ResponseBody
	public HotelWithBLOBs findAllHotelWithBLOBs(Hotel hotel){
		System.out.println("------------");
		return hotelServiceImp.findAllHotelWithBLOBs(hotel);
		
	}
}
